Class ClockDisplay12

java.lang.Object
  extended by ClockDisplay12

public class ClockDisplay12
extends java.lang.Object

The ClockDisplay class implements a digital clock display for a European-style 24 hour clock. The clock shows hours and minutes. The range of the clock is 00:00 (midnight) to 23:59 (one minute before midnight). The clock display receives "ticks" (via the timeTick method) every minute and reacts by incrementing the display. This is done in the usual clock fashion: the hour increments when the minutes roll over to zero.

Version:
2011.07.31, May 14, 2016
Author:
Michael Kölling and David J. Barnes, Aly Moursy, 100910299

Field Summary
static java.lang.String AM
           
static java.lang.String PM
           
 
Constructor Summary
ClockDisplay12()
          Constructor for ClockDisplay objects.
ClockDisplay12(int hour, int minute, java.lang.String choice)
          Constructor for ClockDisplay objects.
 
Method Summary
 java.lang.String getTime()
          Return the current time of this display in the format HH:MM.
 void setTime(int hour, int minute, java.lang.String choice)
          Set the time of the display to the specified hour and minute.
 void timeTick()
          This method should get called once every minute - it makes the clock display go one minute forward.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AM

public static final java.lang.String AM
See Also:
Constant Field Values

PM

public static final java.lang.String PM
See Also:
Constant Field Values
Constructor Detail

ClockDisplay12

public ClockDisplay12()
Constructor for ClockDisplay objects. This constructor creates a new clock set at 12:00a.m. Changed the new rollover limit to 13 so the clock the new limits for time are 1 to 12


ClockDisplay12

public ClockDisplay12(int hour,
                      int minute,
                      java.lang.String choice)
Constructor for ClockDisplay objects. This constructor creates a new clock set at the time specified by the parameters and if the time is am/pm. display between 1 and 12. if invalid input time defaults to 12:00 if invalid input string "choice" (am/pm) defaults to "a.m."

Parameters:
hour: - the hour that the user would like the clock
minute: - the minute that will be displayed if 60 rollsover to 0.
choice: - lets the user choose if the time is am/pm.
Method Detail

getTime

public java.lang.String getTime()
Return the current time of this display in the format HH:MM.


setTime

public void setTime(int hour,
                    int minute,
                    java.lang.String choice)
Set the time of the display to the specified hour and minute. if minute is 60 hours increments by 1 and minutes increments to 0.

Parameters:
hour: - the hour that the user would like the clock
minute: - the minute that will be displayed if 60 rollsover to 0.
choice: - lets the user choose if the time is am/pm.

timeTick

public void timeTick()
This method should get called once every minute - it makes the clock display go one minute forward. if time is 11:59 am/pm and timeTick is invoked am becomes pm and pm becomes am